<?php
/**
 * View for example application 1.
 */
class View_App1 extends Psa_Plugin_View{

	/**
	 * Renders even_numbers.tpl template and puts rendered html in "result" smarty value
	 */	
	function even_numbers(){
		$rendered_result = $this->psa_smarty->fetch("example_app1/even_numbers.tpl");
		$this->psa_smarty->assign("result", $rendered_result);
	}
	
	/**
	 * Renders odd_numbers.tpl template and puts rendered html in "result" smarty value
	 */
	function odd_numbers(){
		$rendered_result = $this->psa_smarty->fetch("example_app1/odd_numbers.tpl");
		$this->psa_smarty->assign("result", $rendered_result);
	}	
	
	/**
	 * Renders prim_numbers.tpl template and puts rendered html in "result" smarty value
	 */
	function prim_numbers(){
		$rendered_result = $this->psa_smarty->fetch("example_app1/prim_numbers.tpl");
		$this->psa_smarty->assign("result", $rendered_result);
	}

	/**
	 * Main template render and display method.
	 * Every application should have one method like this for one controller.
	 * This method can be written to determine if request is made by ajax or not and echo only
	 * ajax result or whole html page.
	 */
	function generate_html(){
		
		$rendered_menu = $this->psa_smarty->fetch("example_app1/menu.tpl");
		$rendered_header = $this->psa_smarty->fetch("example_app1/header.tpl");
		
		$this->psa_smarty->assign("header", $rendered_header);
		$this->psa_smarty->assign("menu", $rendered_menu);
		
		echo $this->psa_smarty->fetch("example_app1/main.tpl");
	}
}
?>